//
//  LBTILivewCollectionViewCell.m
//  AFNetworking
//
//  Created by 刘文扬 on 2018/4/23.
//

#import "LBTILivewCollectionViewCell.h"
#import <Masonry.h>
#import "LBTILiveConfig.h"
#import "LBAVBaseView.h"
#define maxCount 4

@interface LBTILivewCollectionViewCell()

/** imageView*/
@property(nonatomic,strong)UIImageView *imageView;

/** label*/
@property(nonatomic,strong)UILabel *nameLabel;

@end

@implementation LBTILivewCollectionViewCell


-(instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {

        [self initSubViews];
    }
    return self;
}

+(CGSize)sizeForItem:(id)data indexPath:(NSIndexPath *)indexPath totalListNumber:(NSInteger)totalListNumber
{
    return CGSizeZero;
}

-(void)configCellWithData:(id)data atIndexPath:(NSIndexPath *)indexPath totalListNumber:(NSInteger)totalListNumber
{
    //virtual methods
    
    LBAVMemberModel *memberModel = data;
    
    if (memberModel.userId == nil) {
        
        self.nameLabel.hidden = self.imageView.hidden = YES;
        
    }else{
        self.nameLabel.hidden = self.imageView.hidden = NO;
    }
    
    self.nameLabel.text = memberModel.userName;
}


-(void)initSubViews
{
    [self addSubview:self.imageView];
    [self addSubview:self.nameLabel];
    
    
    [self.imageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.leading.trailing.offset(0);
        make.height.mas_equalTo(lb_itemHeight);
    }];
    
    [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.imageView.mas_bottom).offset(5);
        make.centerX.offset(0);
        make.leading.offset(0);
        make.trailing.offset(0);
    }];
}

-(UIImageView *)imageView
{
    if (_imageView == nil) {
        
        UIImageView *imageView = [[UIImageView alloc] init];
        imageView.backgroundColor = [UIColor blackColor];
        _imageView = imageView;
        
    }
    return _imageView;
}

-(UILabel *)nameLabel
{
    if (_nameLabel == nil) {
        
        UILabel *label = [[UILabel alloc] init];
        label.font = [UIFont systemFontOfSize:14];
        label.textColor = [UIColor whiteColor];
        label.numberOfLines = 1;
        _nameLabel = label;
        
    }
    return _nameLabel;
}

@end
